<!--
 * @Author: liangzhuo liangzhuo@chzu.com
 * @Date: 2022-05-07 11:12:08
 * @LastEditors: liangzhuo liangzhuo@chzu.com
 * @LastEditTime: 2022-05-07 11:12:34
 * @FilePath: \ruoyi-ui\src\components\Template\chartTemplate.vue
 * @Description: echarts 模板页
-->
<template>
  <div :class="className" ref="chartDiv" :style="{ height: height, width: width }" />
</template>

<script>
import echarts from "echarts";
require("echarts/theme/macarons"); // echarts theme
import resize from "@/views/dashboard/mixins/resize.js";

const animationDuration = 6000;

export default {
  mixins: [resize],
  props: {
    className: {
      type: String,
      default: "chart",
    },
    width: {
      type: String,
      default: "100%",
    },
    height: {
      type: String,
      default: "100%",
    },
  },
  data() {
    return {
      chart: null,
    };
  },
  mounted() {
    this.$nextTick(() => {
      this.initChart();
    });
  },
  beforeDestroy() {
    if (!this.chart) {
      return;
    }
    this.chart.dispose();
    this.chart = null;
  },
  methods: {
    initChart() {
      this.chart = echarts.init(this.$el, "macarons");
      const size = this.$refs.chartDiv.offsetWidth;
      this.chart.setOption({

      });
    },
  },
};
</script>
